package com.cn.design.state;

/**
 * @author: zhangyiting
 * @description: 客户端代码，没有任何改动。但我们的程序却更加灵活易变
 * @createDate: Created in 2022/7/5 23:13
 * @version: 1.0
 */
import lombok.Data;
@Data
public class Work {
    private int hour;

    private Boolean finish = false;

    private State state;

    public Work() {
        state = new ForenoonState();
    }


    public void writeProgram() {
        this.state.writeProgram(this);
    }


    public static void main(String[] args) {

        Work emergencyProjects = new Work();
        emergencyProjects.hour = 9;
        emergencyProjects.writeProgram();
        emergencyProjects.hour = 10;
        emergencyProjects.writeProgram();
        emergencyProjects.hour = 12;
        emergencyProjects.writeProgram();
        emergencyProjects.hour = 13;
        emergencyProjects.writeProgram();
        emergencyProjects.hour = 14;
        emergencyProjects.writeProgram();
        emergencyProjects.hour = 17;
        emergencyProjects.writeProgram();

        emergencyProjects.finish = true;

        emergencyProjects.writeProgram();
        emergencyProjects.hour = 19;
        emergencyProjects.writeProgram();
        emergencyProjects.hour = 22;
        emergencyProjects.writeProgram();
    }
}

